package com.dell.chen.dao.impl;

import com.dell.chen.dao.SortDao;
import com.dell.chen.pojo.Sort;

import java.util.List;

/**
 * @author ：ChenwithIU
 * @date ：Created in 2020/12/2 9:18
 */
public class SortDaoImpl extends BaseDao implements SortDao {

    @Override
    public int addSort(Sort sort) {
        String sql = "insert into f_sort(`id`,`typeName`) values(?,?)";
        return update(sql,sort.getId(),sort.getTypeName());
    }

    @Override
    public int deleteSort(Integer id) {
        String sql = "delete from f_sort where id = ?";
        return update(sql,id);
    }

    @Override
    public int updateSort(Sort sort) {
        String sql = "update f_sort set `typeName`=? where id = ?";
        return update(sql,sort.getTypeName(),sort.getId());
    }

    @Override
    public Sort querySortById(Integer id) {
        String sql = "select `id`,`typeName` from f_sort where id = ?";
        return queryForOne(Sort.class,sql,id);
    }

    @Override
    public List<Sort> querySort() {
        String sql = "select `id`,`typeName` from f_sort ";
        return queryForList(Sort.class,sql);
    }
}
